package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.query.album.TrackInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {

    /**
     * 分页查询声音数据
     *
     * @param page
     * @param trackInfoQuery
     * @return
     */
    IPage<TrackListVo> selectUserTrackPage(
            Page<TrackListVo> page,
            @Param("vo") TrackInfoQuery trackInfoQuery
    );

    /**
     * 分页查询专辑声音数据
     *
     * @param page
     * @param albumId
     * @return
     */
    IPage<AlbumTrackListVo> selectAlbumTrackPage(Page<AlbumTrackListVo> page,@Param("albumId") Long albumId);

    @Update("update track_stat set stat_num = stat_num+#{count} where track_id = #{trackId} and stat_type = #{statType} and is_deleted = 0")
    void updateTrackStat(@Param("count") Integer count, @Param("trackId") Long trackId, @Param("statType") String statType);
}
